[vtkusers] How to get silhouette/mask of rendered polydata?

David Gobbi dgobbi at atamai.com
Mon May 8 17:27:30 EDT 2006


Hi Michael,

There isn't a look vector.  Imagine something like vtkContourFilter in 
reverse.  With vtkContourFilter, you would be able to take an image and 
produce a polydata contour in the same coordinate system as the image.  
With vtkPolyDataToImageStencil, you would start with a polydata and 
generate a mask that exists in the same coordinate system as that polydata.

So you're probably still wondering how it figures out the aspect ratio 
(or, more specifically, the voxel spacing).  The answer is that when the 
stencil is applied to an image, the stencil looks at the Spacing and 
Origin of the image data and uses those values.

Everything is done in the VTK "data" coordinate system and the camera 
orientation is not involved.

 - David


marice at knology.net wrote:
> I looked at the vtkPolyDataToImageStencil and vtkImageStencil classes and
> they are almost what I need. Maybe I'm not understanding them, but I don't
> see how to take into account the perspective rendering and the pixel aspect
> ratio, which should change the mask.
>
> The on-line documentation for vtkPolyDataToImageStencil doesn't specify how
> the vtkPolyData is mapped into image space and I didn't see any of the image
> stencil classes documented in the VTK books. My confusion is how to specify
> the "look vector" (e.g., a camera location and orientation) so the filter
> knows how to do the mapping. Is it always along a fixed vector?
>
> Michael
>
> On Mon, 08 May 2006 10:43:16 -0400, David Gobbi <dgobbi at atamai.com> wrote :
>
>   
>> Hi Michael,
>>
>> There is a filter that does this in 3D, it is called 
>> vtkPolyDataToImageStencil.  There is not yet a VTK filter that does it 
>> for 2D polydata.
>>
>> However, if you look at 
>> VTK/Widgets/Testing/Cxx/TestImageTracerWidget.cxx (look in Hybrid if you 
>> have VTK 4) there is an example of converting a 2D polydata to a 3D 
>> polydata with extrusion.  Not quite ideal, but it should work.
>>
>>  - David
>>
>>
>> Michael Rice wrote:
>>     
>>> I am rendering a vtkImageData as the background image and a 
>>> vtkPolyData on top of it. What I need to do is get the elements from 
>>> the vtkImageData that are beneath the rendered vtkPolyData. Basically 
>>> I'm trying to use the vtkPolyData to generate a mask for the image.
>>>
>>> I thought of using a clip plane on the poly data, but I don't think 
>>> that will take into account the perspective rendering and the pixel 
>>> aspect ratio. Is that correct?
>>>
>>> Does anyone have any hints or examples on how I can do this?
>>>
>>> Thanks.
>>> Michael
>>> _______________________________________________
>>> 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