[Insight-developers] The quest for a fast polygon set to binary image filter.

kent williams norman-k-williams at uiowa.edu
Thu Aug 6 16:01:07 EDT 2009


Before I start on this has anyone else had a crack at this problem?

I want to generate a mask image from as set of polygons (generated by
BRAINSTracer).  Currently what I do is basically

for each polygon
  find bounds of polygon
  for each voxel in bounds
    if voxel's position is inside the polygon then
      voxel = 255
    else
      voxel = 0
    endif
  endfor
endfor

As you can imagine, this is not super speedy, especially since my polygons
are derived (by vtkContourRepresentation) from a set of spline control
points, so each test for polygon membership has to contend with potentially
hundreds of vertices.

I've spent most of today googling and trying things out before getting
really frustrated.  What I have is a set of polygons, each of which lies on
a 2D slice, and I want to generate a mask volume where every point inside
any of the polygon is inside the mask.

The best starting point I've found is this code from Graphics Gems:
http://tog.acm.org/resources/GraphicsGems/gems/ConcaveScan.c

This is pretty easily parallelizable on the per-slice level.

But adapting this code is non-trivial for a number of reasons.  So has
anyone else attacked this?

I know about PolylineMask2DImageFilter and PolylineMaskImageFilter, but the
former only works for convex polygons, and I can't figure out what the
latter would do forme.



More information about the Insight-developers mailing list