[vtkusers] problem with vtkImageOpenClose3D

Mark Roden mmroden at gmail.com
Fri Dec 10 14:27:36 EST 2010


Hi all,

I'm having a problem with vtkImageOpenClose3D.  It seems that no
matter what the radius I give to the filter, it's only closing by a
single pixel.

Here's my method (java, vtk v 5.6)

    private void ErodeDilateBinary(vtkImageData inBinaryImage){
        vtkImageOpenClose3D theOpenClose = new vtkImageOpenClose3D();
        //theOpenClose.SetOpenValue(0);
        theOpenClose.SetCloseValue(100);

        int theRadius = (int)(((radii[0] > radii[1]? radii[0] :
radii[1]) * 0.25) + 0.5);
        if (theRadius < 1) theRadius = 1;

        int[] erodeDilateKernel = new int[3];
        switch (panel.getOrientation()) {
            case OrthoPanel.ORIENTATION_XY:
                erodeDilateKernel[0] = theRadius;
                erodeDilateKernel[1] = theRadius;
                erodeDilateKernel[2] = 1;
            break;
            case OrthoPanel.ORIENTATION_XZ:
                erodeDilateKernel[0] = theRadius;
                erodeDilateKernel[1] = 1;
                erodeDilateKernel[2] = theRadius;
            break;
            case OrthoPanel.ORIENTATION_YZ:
                erodeDilateKernel[0] = 1;
                erodeDilateKernel[1] = theRadius;
                erodeDilateKernel[2] = theRadius;
            break;
        }
        theOpenClose.SetKernelSize(erodeDilateKernel[0],
erodeDilateKernel[1], erodeDilateKernel[2]);
        theOpenClose.SetInput(inBinaryImage);
        theOpenClose.Update();
        inBinaryImage = theOpenClose.GetOutput();

    }
theRadius, in this case, is 11, and orientation is XY.

I'm trying to remove small (no larger than four or five pixels) holes
from a binary mask.  The single pixel holes are removed, but the
larger holes remain.  I would think that with a radius of 11, anything
smaller than 8 or so pixels (given topology, of course...) would be
erased.  Is there something I'm missing here?  Once a hole is filled,
it shouldn't be able to come back, right?

Thanks for any help,
Mark



More information about the vtkusers mailing list