[vtkusers] How to render the contours of a binary image?

Thomas Kilgus t.kilgus at dkfz-heidelberg.de
Tue May 31 07:19:26 EDT 2011


Hi,

I am using a vtkPolyDataMapper to render images as a texture on a plane. 
Some images (in the form of vtkImageData) just consist of the values 1.0 
and 0.0. By means of a vtkLookuptable I can easily render those images 
with a single color (the 1.0 values) and with a transparent background 
(0.0 values). What would be the best way to render just the contours of 
those images?

I already found the vtkContourFilter. But when I use it like this:

       vtkSmartPointer<vtkContourFilter> contourFilter = 
vtkSmartPointer<vtkContourFilter>::New();
       contourFilter->SetInput(image);
       contourFilter->GenerateValues(1, 1.0, 1.0);
       contourFilter->Update();
       texture->SetInputConnection(contourFilter->GetOutputPort());

the whole image is just rendered as a single color.

Is there anything wrong with my code or is the vtkContourFilter just not 
the appropriate filter for my task?

regards
thomas kilgus



More information about the vtkusers mailing list