[vtkusers] Fwd: best way to clip vtkImageData using vtkPloyData

Prathamesh Kulkarni prathameshmkulkarni at gmail.com
Fri Jul 16 12:14:21 EDT 2010


My message did not get posted in the digest, so sending again.

Hope some one can direct me.

Thanks,
Prathamesh

---------- Forwarded message ----------
From: Prathamesh Kulkarni <prathameshmkulkarni at gmail.com>
Date: Fri, Jul 16, 2010 at 12:05 AM
Subject: Re: [vtkusers] best way to clip vtkImageData using vtkPloyData
To: David Gobbi <david.gobbi at gmail.com>
Cc: VTK Mailing List <vtkusers at vtk.org>


I managed to add more than one stencils by using the
combined_vtkImageStencilData->Add(new_vtkImageStencilData) and then setting
vtkImageStencil->AddStencil(combined_vtkImageStencilData);

However, I have not been able to figure out a way to set the foreground
color of any stencil to a given value. The aim is to show every stencil with
a different color in the vtkImageData (= vtkImageStencil->GetOutput()).

Any help will be highly appreciated.


Thanks,
Prathamesh

On Thu, Jul 15, 2010 at 6:52 PM, Prathamesh Kulkarni <
prathameshmkulkarni at gmail.com> wrote:

> I managed use vtkImageStencil and vtkImageAccumulate, but could not get a
> proper blended image output with vtkImageBlend. Following is my code snippet
> for vtkImageBlend:
>
>         blended_image->SetInput(image_data);
>         blended_image->SetStencil(image_stencil_data);
>
>         blended_image->SetOpacity(1, opacity)
>         blended_image->Update();
>
> When I try to render blended_image->GetOutput(), I simply get the input
> image, as if setting the stencil had no effect. I expected to see a
> different opacity in the stencil region. Please tell me if I am missing
> anything here.
>
>
> Also, I was wondering how to add multiple stencils to vtkImageStencil so
> that at the output I can have a vtkImageData showing multiple stencils with
> different colors.
>
> In any case, I did not understand how to set the foreground color of a
> single stencil.
>
>
>
> Sorry for putting in 3 questions together.. Thanks for your answers in
> advance.
>
>
> Prathamesh
>
>
> On Wed, Jul 14, 2010 at 5:31 PM, David Gobbi <david.gobbi at gmail.com>wrote:
>
>> Hi Prathamesh,
>>
>> You should use either vtkClipVolume or vtkImageStencil, based on what
>> you want as an output. The vtkClipVolume filter will output an
>> unstructured grid, i.e. it will produce a geometric data set
>> consisting of voxel cells (each voxel cell will be a little cube with
>> eight points at its corners).  If you want the output to be an actual
>> image, with the background set to black or to transparent, then you
>> should use vtkImageStencil.
>>
>> In either case, the best place to start is vtkImplicitLoop, which
>> takes a contour and produces an "implicit function", which in
>> VTK-speak, is a function used to define the inside vs. the outside of
>> a selection area.  Then the vtkImplicitLoop can be used as an input to
>> vtkImplicitFunctionToImageStencil.  The output of
>> vtkImplicitFunctionToImageStencil can then be used as an input to e.g.
>> vtkImageBlend (for pasting a cut-out image onto another image),
>> vtkImageStencil (for blacking out the non-selected region of the
>> image), or vtkImageAccumulate (for computing the average value,
>> standard deviation, or the histogram of the image area inside the
>> stencil).
>>
>>   David
>>
>>
>>
>>
>> On Wed, Jul 14, 2010 at 4:13 PM, Prathamesh Kulkarni
>> <prathameshmkulkarni at gmail.com> wrote:
>> >
>> > Hello all,
>> >
>> > I want to extract a sub-image from vtkImageData given a closed set of
>> points
>> > forming any arbitrary shape (may be a vtkPolyData).
>> >
>> > I have been looking at vtk classes like vtkClipVolume, vtkExtractVOI,
>> > vtkImageStencil. I am no able to understand which way should be
>> preferred
>> > over which to do my task. Also, I am not able to figure out the exact
>> > pipeline structure for these clipping methods.
>> >
>> > Could someone please throw some light on this?
>> >
>> > Thanks,
>> > Prathamesh
>> >
>> > _______________________________________________
>> > Powered by www.kitware.com
>> >
>> > Visit other Kitware open-source projects at
>> > http://www.kitware.com/opensource/opensource.html
>> >
>> > Please keep messages on-topic and check the VTK FAQ at:
>> > http://www.vtk.org/Wiki/VTK_FAQ
>> >
>> > Follow this link to subscribe/unsubscribe:
>> > http://www.vtk.org/mailman/listinfo/vtkusers
>> >
>> >
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100716/cee68f87/attachment.htm>


More information about the vtkusers mailing list