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

Michael Rice marice at knology.net
Tue May 9 00:12:55 EDT 2006


Thanks for the explanation, I think I now have a basic understanding  
of what it's doing. Unfortunately, I don't think it's going to work  
for me.

In the end, I need to be able to render the silhouette of the  
polydata in realtime as the user manipulates the camera location. For  
example, the web page below shows two camera shots of a polydata. As  
the user rotates the polydata in one window, I need to render the  
stencil image in another window. Optimally, I'll be able to associate  
each pixel in the rendered stencil image back to a cell in the polydata.

http://www.knology.net/~mars/stencil.html

Michael

On May 8, 2006, at 4:27 PM, David Gobbi wrote:

> 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