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

Dominik Szczerba dominik at itis.ethz.ch
Thu Jun 16 08:23:36 EDT 2011

To see the contours of my voxel based segmentation fields I threshold
the binary dataset and extract its edges. This is, however, very
expensive, as the result is an unstructured dataset.


On Thu, Jun 16, 2011 at 1:56 PM, Thomas Kilgus
<t.kilgus at dkfz-heidelberg.de> wrote:
> 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
> _______________________________________________
> Powered by www.kitware.com
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers

More information about the vtkusers mailing list