[vtk-developers] Use vtkContour to find outline of mask in vtkImageData?

Karthik Krishnan karthik.krishnan at kitware.com
Mon Jan 14 18:17:04 EST 2008


Kent:

Sorry for the long overdue reply.  Yes there is a way to do this.

The method you're looking for is

  vtkContourWidget::Initialize( polydata_containing_contour_control_points,
StartingWidgetState )

What this does is to take a vtkPolyData (that contains 2 or more points and
just one cell) and populate a contour from it.

StartingWidgetState as the documentation states can be
vtkContourWidget::Define or vtkContourWidget::Manipulate. The former will
let you go about adding new points. The latter puts it into manipulate
state, (the same state you have on a vtkContourWidget, after you add the
last point or close the loop).

----------
Now for the caveat:

I had a similar situation a while ago where I needed to go from a binary
representation to a parametric representation, for editing purposes.
If you run a vtkContourFilter and get a polydata out, you will have a
polydata with several cells. You'll need to extract out each of those cells
into seperate vtkPolydata. Take one of these cells. It will contain several
points. If you initialize a contour widget from it, it will work, but it
will have a few hundred control points and that doesn't look pretty. You can
try it out :)

What you need is a downsampler, that picks every nth point, or better still
a smart one that picks the ones that lie on high curvature.
----------

I just added a test that demonstrates initializing a contour widget from a
user-supplied polydata. (a closed circle in this case).

Please let us know if you have issues.

--
Karthik Krishnan
R&D Engineer,
Kitware Inc.


On 1/9/08, kent williams <nkwmailinglists at gmail.com> wrote:
>
> I posted this to VTKUsers and got no suggestions.  Anyone here want to
> comment?
>
> I need to go from a binary image, representing a 3D mask, to a set of
> outlines on each slice of the binary image.
>
> It seems like something like this would work:
>
> Use vtkImageReslice to extract 2D slices from the 3D volume
> For each slice, use vtkContourFilter to extract contours around areas
> of set pixels.
>
> Right now I have a tracer that uses one or more vtkContourWidgets to
> interactively generate a set of contours defining a mask.  I just
> finished code that iterates through the contour set a slice at a time,
> and generates a binary image volume where a non-zero pixel value is
> inside the mask, and zero pixel value is outside the mask.  What I
> want to do is reverse this process -- given a binary image, generate
> the countour set.
>
> It looks like I should maybe use GenerateValues to generate contours,
> but I don't understand the relationship between the output data of
> vtkContour filter and the data i would need to initialize a
> vtkContourWidget.  The few examples extant don't make that clear to me
> either.
>
> Thanks!
> _______________________________________________
> vtk-developers mailing list
> vtk-developers at vtk.org
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20080114/d9007c77/attachment.html>


More information about the vtk-developers mailing list