[vtkusers] vtkImageStencilData to vtkImageData
David Gobbi
david.gobbi at gmail.com
Thu Jul 31 11:46:01 EDT 2008
Hi Luis,
The output of vtkPolyDataToImageStencil is not a vtkImageData.
It is a vtkImageStencilData, which is something quite different.
You are probably confused because vtkImageStencil is not the
tool you are looking for, you are looking for a screwdriver that
will convert a vtkPolyData into an image but there is no filter
in VTK that does exactly that. So instead, to do what you want,
I'm giving you advice on the Rube Goldberg machine that you
will need to build in order to get the job done in VTK.
The good news is, you are almost there. The only thing left is
that you need to create a blank image for the Input of
vtkImageStencil, because the purpose of vtkImageStencil
is to take an existing image and then fill the region inside
(or outside) the stencil with a different color. So, you want
to start with a black image, and then color the region inside
the polydata white.
Unfortunately there is no source in VTK that is made to
create a blank image, so you have to use something
like vtkImageGridSource and then set the lines and the
background for the source to black (Rube Goldberg
comes to mind again). Then use the output of this
as the Input of vtkImageStencil.
David
On Thu, Jul 31, 2008 at 11:26 AM, Luis Cordova <cordoval at gmail.com> wrote:
> I am confused since I have
>
> /* convert poly to image data */
> vtkPolyDataToImageStencil *imagedata = vtkPolyDataToImageStencil::New();
> imagedata->SetInput(decimate->GetOutput());
>
> /* second step needed applies the stencil to an image */
> vtkImageStencil *stencil = vtkImageStencil::New();
> stencil->SetInput(imagedata->GetOutput());
> stencil->SetStencil(imagedata->GetOutput());
> stencil->ReverseStencilOn();
> stencil->SetBackgroundValue(500);
>
> And SetInput and SetStencil are provided the same input. I am
> missunderstanding something serious.
>
> On Thu, Jul 31, 2008 at 8:14 AM, David Gobbi <david.gobbi at gmail.com> wrote:
>> Hi Luis,
>>
>> Two steps are required. First vtkPolyDataToImageStencil, and then
>> vtkImageStencil to apply the stencil to an image. See the following
>> example:
>>
>> Hybrid/Testing/Tcl/TestImageStencilWithPolydata.tcl
>>
>> If you just want to create a binary image, then you will have to
>> replace the "reader" in the example with something that will
>> create a blank image.
>>
>> David
>>
>>
>> On Thu, Jul 31, 2008 at 1:43 AM, Luis Cordova <cordoval at gmail.com> wrote:
>>> I am getting a runtime error of "type vtkImageStencilData, but a
>>> vtkImageData is required."
>>>
>>> I was before needing to convert from PolyData to ImageData, then I use
>>> vtkPolyDataToImageStencil, but now this error from Stencil to Image.
>>>
>>> Anyone hints?
>>>
>>> Thanks,
>>> _______________________________________________
>>> This is the private VTK discussion list.
>>> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>
>
More information about the vtkusers
mailing list