[vtkusers] image masking pb
David Gobbi
dgobbi at imaging.robarts.ca
Tue Dec 16 00:05:23 EST 2003
Hi Dean,
The vtkImplicitFunctionToImageStencil does not check the MTime of the
input ImplicitFunction, that is why the stencil doesn't update. Since
a vtkImplicitFunction isn't a vtkDataObject, the VTK pipeline mechanism
doesn't automatically take care of the updating.
Conversely, the vtkPolyDataToImageStencil is a true VTK filter that
has a vtkDataObject as both input and output, and the pipeline behaves as
expected.
The vtkImplicitFunctionToImageStencil works by evaluating the
ImplicitFunction at every voxel within the UpdateExtent of the ImageData
that is being stenciled, which is fairly inefficient.
The vtkPolyDataToImageStencil works by looking at where the raster lines
of the image (i.e. lines of constant z,y) intersect the PolyData,
and hence is very efficient as long as the PolyData is not too complex.
- David
On Mon, 15 Dec 2003 dean.inglis at camris.ca wrote:
> Hi David,
>
> I tried vtkImplicitSelectionLoop in a tcl/tk
> tester pipeline:
>
> vtkPolyData spoly
> vtkPoints spoints
>
> vtkImplicitSelectionLoop loop
> loop SetLoop spoints
> loop SetNormal 1 0 0
> loop AutomaticNormalGenerationOn
>
> vtkImplicitFunctionToImageStencil if2is
> if2is SetInput loop
>
> vtkImageStencil stencil
> stencil SetInput [extract GetOutput]
> stencil SetStencil [if2is GetOutput]
> stencil ReverseStencilOn
> stencil SetBackgroundValue 128
> stencil ReleaseDataFlagOff
>
> which gets passed onto a vtkImageActor when
> the points making up the loop are defined by a
> closed splinewidget. The stencil works once and
> either it or the vtkImageActor refuses to update
> when the points change (their number is the same
> but their positions change).
>
> What seems to work faster and does update with
> changed point positions is this pipeline:
>
> vtkPolyData spoly
>
> vtkLinearExtrusionFilter extrude
> extrude SetInput spoly
> extrude SetScaleFactor 1
> extrude SetExtrusionTypeToNormalExtrusion
> extrude SetVector 1 0 0
>
> vtkPolyDataToImageStencil dataToStencil
> dataToStencil SetInput [extrude GetOutput]
>
> vtkImageStencil stencil
> stencil SetInput [extract GetOutput]
> stencil SetStencil [dataToStencil GetOutput]
> stencil ReverseStencilOff
> stencil SetBackgroundValue 128
>
> Any idea why the first pipeline refuses to
> update?
>
> thanks for your help,
> Dean
>
> >
> > The vtkImplicitSelectionLoop works good for this, but it there isn't
> > any filter to convert a vtkPolyData into a SelectionLoop, you have to
> > do it by hand.
> >
> > Once you have a vtkImplicitSelectionLoop, you can convert it into a
> > "stencil" with the vtkImplicitFunctionToImageStencil filter. A "stencil"
> > is essentially a masked region that has been compressed into run-lengths,
> > a few of the image filters take a stencil as an additional input.
> >
> > There is also a vtkPolyDataToImageStencil filter, but it is meant for
> > closed polyhedral surfaces, not for closed 2D polygons.
> >
> > - David
>
>
More information about the vtkusers
mailing list