[vtkusers] How to render the pixel contour of an image

Thomas Kilgus t.kilgus at dkfz-heidelberg.de
Thu Jun 16 07:56:55 EDT 2011


Hi,

I have a CT data set and a corresponding segmentation (binary image 
containing only 0 and 1 values). I would like to render the contour 
along the pixels of the "binary" image. I tried to use the 
vtkMarchingSquares filter which is meant for image contouring. However, 
the achieved output is not what I want.

Attached you can find screenshots illustrating my issue. The image 
filterOutput.png shows the contour (red) generated by the filter. The 
other screenshot shows the actual binary image (red) which contains in 
fact a few more pixels at the boundaries. I would like to render the 
"stepped" line - the edges of the red image - and not diagonal lines 
which cross a pixel in the middle. Additionally, some pixels are left 
out for some reason.

The following code is used to generate the contour:

vtkSmartPointer<vtkMarchingSquares> contourFilter = 
vtkSmartPointer<vtkMarchingSquares>::New();
contourFilter->SetInput(binaryImage);
contourFilter->SetValue(1, 1.0);
contourFilter->Update();
mapper->SetInputConnection(contourFilter->GetOutputPort());

Is there any easy way to achieve the stepped and correct contour?

Regards
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BinaryImage.png
Type: image/png
Size: 1769 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110616/334731ce/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: filterOutput.png
Type: image/png
Size: 3860 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110616/334731ce/attachment-0001.png>


More information about the vtkusers mailing list