fill closed contours

Hi,
I want assing a 255 value for pixels inside a contour and 0 for outside pixels. the contour is composed of a set of 3D points that have same z-value. are there a vtk filters that allow to do that? vtkPolygon::PointinPolygon does not seem give good results (because a closed contour is transformed to a filled square). I want obtain result like in figure.

thank’s in advance

You can try vtkPolyDataToImageStencil, or create a polygon and use probe filter to sample on a regular grid.

Would you like to create a 3D volume from a DICOM RT structure set? That requires special techniques - these general-purpose rasterization methods would not work.

Hi professor;

thank’s for the response. I have tried [vtkPolyDataToImageStencil but it seems not work.
You are right, I would like create a 3D volume from Dicom RT series. you have montioned that there are special techniques to do that. can you give me more precision please?. It is still the only issue to implement the implicit models.

Thank’s in advance

Converting DICOM RT structure set to binary labelmap is a very complex operation, as you need to handle inter-plane interpolation/splitting/merging, intra-plane splitting, end-capping, and keyhole resolution. These are all implemented and thoroughly tested on thousands of clinical data sets and made available for free in 3D Slicer’s SlicerRT extension. You can use Slicer’s GUI or convert in batch mode (a few lines of Python script). If you cannot figure out how to do something in Slicer then post your question to the Slicer forum.

1 Like

Hi professor.

How can create a polygon from a contour in slicerRT? can I use vtkContourTriangulator filter?

thank’s in advance

vtkContourTriangulator is not applicable here, as it creates planar polygons from a set of contours on a single plane, while you need to reconstruct closed 3D surfaces from contours on many planes.

Among built-in VTK filters, vtkRuledSurfaceFilter is the closest to what you would need, but it does not work in this case, because its assumptions about the input and output data are not valid for DICOM RT structure sets (for example, it does not know about the keyhole technique at all and as far as I remember it does not cope well with splitting/merging of branches, and the distance factor heuristics does not work robustly either).