Search in sources :

Example 1 with Segment3DImage

use of mcib3d.image3d.Segment3DImage in project mcib3d-core by mcib3d.

the class IntImage3D method binaryReconstructByObjects.

public ImageInt binaryReconstructByObjects(ImageInt base) {
    // System.out.println("max "+this.getMaximum());
    Segment3DImage seg = new Segment3DImage(new ImageShort(this.getStack()), 1, 65535);
    seg.segment();
    ImageInt label = seg.getLabelledObjectsImage3D();
    boolean[] ok = new boolean[(int) label.getMax() + 1];
    for (int i = 0; i < ok.length; i++) {
        ok[i] = false;
    }
    if (label.getMax() > 0) {
        for (int k = 0; k < sizez; k++) {
            for (int j = 0; j < sizey; j++) {
                for (int i = 0; i < sizex; i++) {
                    if (base.getPixel(i, j, k) != 0) {
                        ok[label.getPixelInt(i, j, k)] = true;
                    }
                }
            }
        }
        for (int k = 0; k < sizez; k++) {
            for (int j = 0; j < sizey; j++) {
                for (int i = 0; i < sizex; i++) {
                    int pix = label.getPixelInt(i, j, k);
                    if (pix > 0) {
                        if (ok[pix]) {
                            label.setPixel(i, j, k, 255);
                        } else {
                            label.setPixel(i, j, k, 0);
                        }
                    }
                }
            }
        }
    }
    return label;
}
Also used : ImageShort(mcib3d.image3d.ImageShort) ImageInt(mcib3d.image3d.ImageInt) Segment3DImage(mcib3d.image3d.Segment3DImage)

Aggregations

ImageInt (mcib3d.image3d.ImageInt)1 ImageShort (mcib3d.image3d.ImageShort)1 Segment3DImage (mcib3d.image3d.Segment3DImage)1