Kent:<br><br>As I understand, you are essentially trying to rasterize a bunch of closed polylines...<br><br>Here are two ways to do this..... (wrong and right)<br><br>---------<br>1. Use vtkPolyDataToImageStencil to generate vtkImageStencilData. And then using vtkImageStencil to generate the rasterized image
<br> See Examples/GUI/Tcl/ImageTracerWidget.tcl <br>On a side note, I have on occassions noted numerical issues with the rasterization done by vtkPolyDataToImageStencil, when you have sharp edges in your polyline, which leads to a streaking effect along an axis..
<br>(see <a href="http://www.vtk.org/pipermail/vtkusers/2007-May/091141.html">http://www.vtk.org/pipermail/vtkusers/2007-May/091141.html</a>)<br><br>That said, this is the quick and dirty approach. The right one (and the faster one is below)....
<br>OBBTrees are an overkill for something as simple as rasterization. And the ImageTracerWidget example in VTK misdirects a lot of people into using this method.<br><br>--------<br>2. vtkPolygon::PointInPolygon will do the job for you...
<br><br>Just get the bounds of the closed polyline. For every pixel in your image that lies within those bounds, check if its world coordinates are within the Polygon and you are done. <br><br>The method is very fast. It just checks the number of times a ray starting at the point intersects the polygon. If it intersects it, even number of times, it is outside, odd implies inside. In reality, it throws a bunch of rays in different directions, and does a voting, to overcome numerical issues that might arize when one or more rays fall exactly on an edge of the polygon.
<br><br>----------<br><br>Good luck :)<br><br>-- <br>Karthik Krishnan<br>R&D Engineer,<br>Kitware Inc.<br><br>PS: If you choose to use method (2), It would be great if you could
wrap it into a VTK filter (deriving from vtkImageAlgorithm) and
contribite it :)<br><br><br>
<br><div><span class="gmail_quote">On 12/14/07, <b class="gmail_sendername">kent williams</b> <<a href="mailto:firstname.lastname@example.org">email@example.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I need to go from a collection of closed polygons each associate with<br>a slice of an image volume, to an image volume defining a mask.<br><br>In other words, for each slice in a volume, I want to set pixels to 1<br>if they're inside a polygon in the collection, and set them to zero if
<br>they're not.<br><br>Suggestions?<br>_______________________________________________<br>This is the private VTK discussion list.<br>Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ">
http://www.vtk.org/Wiki/VTK_FAQ</a><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br></blockquote></div>