Simon Whitaker simon.whitaker at nottingham.ac.uk
Mon Jan 10 05:20:09 EST 2000

Hi, ...

Back in November Adrian Anner wrote:-

"I'm creating a model from segmented volume data(similar to the tcl-example


I use the vtkImageIslandRemoval2D to remove small islands of voxels. I can
display all slices after this filter and it looks fine, but if I call
Update() (to write the data to the file) I get just the first slice. If I
don't use the islandRemover it works fine."

I have encountered exactly the same problem with a similar pipeline
(vtkPNMReader - vtkImageIslandRemoval2D - vtkImageThreshold -
vtkImageShrink3D - vtkImageGaussianSmooth - vtkImageToStructuredPoints -
vtkMarchingCubes - vtkMarchingCubes - vtkDecimate - vtkSmoothPolyDataFilter
- vtkPolyDataNormals - vtkStripper - vtkPolyDataWriter) which is used to
generate models from multiple 3D CT images.

This pipeline, that I had used without trouble with VTK2.0, failed after I
changed over to VTK2.3, producing bizarre models or causing vtkDecimate to
fail due to lack of input data.

I think I have traced the problem to the templated function
vtkImageIslandRemoval2DExecute in vtkImageIslandRemoval2D.cxx. The lines:
        inPtr2 += inInc2;
        outPtr2 += outInc2;
are missing from the final three-level nested loop. The code for this loop
should read:

// Loop though all pixels actually copying and replacing.
for (idxC = 0; idxC < maxC; idxC++)
    outPtr2 = outPtr + idxC;
    inPtr2 = inPtr + idxC;
    for (outIdx2 = outExt[4]; outIdx2 <= outExt[5]; ++outIdx2)
        outPtr1 = outPtr2;
        inPtr1 = inPtr2;
        for (outIdx1 = outExt[2]; outIdx1 <= outExt[3]; ++outIdx1)
            outPtr0 = outPtr1;
            inPtr0 = inPtr1;
            for (outIdx0 = outExt[0]; outIdx0 <= outExt[1]; ++outIdx0)
                if (*outPtr0 == 3)
                   *outPtr0 = replaceValue;
                   *outPtr0 = *inPtr0;
                inPtr0 += inInc0;
                outPtr0 += outInc0;
            inPtr1 += inInc1;
            outPtr1 += outInc1;
        inPtr2 += inInc2;            // missing line
        outPtr2 += outInc2;          // missing line

Once I added these, vtkImageIslandRemoval2D worked fine. I have looked in
the source for VTK2.4 and VTK nightly (today, 10 January) and both these
releases are also missing the same lines.

All the best ...

Dr SC Whitaker
Department of Radiology
University Hospital

This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.

More information about the vtkusers mailing list