Search in sources :

Example 1 with ImageByte

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

the class BinaryMorpho method binaryErode2D.

public static ImageByte binaryErode2D(ImageByte in, float radius) {
    ImageByte temp = (ImageByte) FastFilters3D.filterIntImage(in, FastFilters3D.MIN, radius, radius, 0, 1, false);
    temp.setOffset(in);
    temp.setScale(in);
    return temp;
}
Also used : ImageByte(mcib3d.image3d.ImageByte)

Example 2 with ImageByte

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

the class BinaryMorpho method binaryDilate.

// if no resize of the image, object at the border may be truncated
public static ImageByte binaryDilate(ImageInt in, float radius, float radiusZ, int nbCPUs, boolean enlarge) {
    try {
        if (nbCPUs == 0) {
            nbCPUs = ThreadUtil.getNbCpus();
        }
        ImageInt resize = in;
        // resize
        int reX = (int) (radius + 1);
        int reY = (int) (radius + 1);
        int reZ = (int) (radiusZ + 1);
        if (enlarge)
            resize = (ImageInt) in.enlarge(reX, reY, reZ);
        ImageFloat edm = EDT.run(resize, 0, 1, radius / radiusZ, true, nbCPUs);
        // edm.duplicate().show("edm");
        ImageByte temp = edm.threshold(radius, true, false);
        // temp.show("thres");
        edm.flush();
        edm = null;
        if (enlarge)
            temp.setOffset(in.offsetX - reX, in.offsetY - reY, in.offsetZ - reZ);
        else
            temp.setOffset(in);
        temp.setScale(in);
        return temp;
    } catch (Exception e) {
        exceptionPrinter.print(e, null, true);
    }
    return null;
}
Also used : ImageByte(mcib3d.image3d.ImageByte) ImageInt(mcib3d.image3d.ImageInt) ImageFloat(mcib3d.image3d.ImageFloat)

Example 3 with ImageByte

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

the class BinaryMorpho method binaryCloseMultilabel.

public static ImageInt binaryCloseMultilabel(ImageInt in, float[] radiusXY, float[] radiusZ, int nbCPUs) {
    ImageByte[] ihs = in.crop3DBinary();
    if ((radiusXY.length != ihs.length) || (radiusZ.length != ihs.length)) {
        return null;
    }
    if (ihs != null) {
        // ij.IJ.log("BinaryClose multilabel nb :"+ihs.length);
        for (int idx = 0; idx < ihs.length; idx++) {
            if (radiusXY[idx] <= 1 && radiusZ[idx] <= 1) {
                ihs[idx] = BinaryMorpho.binaryCloseRad1(ihs[idx], 1, nbCPUs);
            } else {
                ihs[idx] = binaryClose(ihs[idx], radiusXY[idx], radiusZ[idx], nbCPUs);
            }
            ihs[idx] = binaryClose(ihs[idx], radiusXY[idx], radiusZ[idx], nbCPUs);
        }
        ImageInt temp = ImageShort.merge3DBinary(ihs, in.sizeX, in.sizeY, in.sizeZ);
        temp.setScale(in);
        temp.setOffset(in);
        return temp;
    }
    return in;
}
Also used : ImageByte(mcib3d.image3d.ImageByte) ImageInt(mcib3d.image3d.ImageInt)

Example 4 with ImageByte

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

the class BinaryMorpho method binaryDilate2D.

public static ImageByte binaryDilate2D(ImageByte in, float radius, boolean enlarge) {
    ImageInt resize = in;
    // resize
    int reX = (int) (radius + 1);
    int reY = (int) (radius + 1);
    int reZ = 0;
    if (enlarge)
        resize = (ImageInt) in.enlarge(reX, reY, reZ);
    ImageByte temp = (ImageByte) FastFilters3D.filterIntImage(resize, FastFilters3D.MAX, radius, radius, 0, 1, false);
    temp.setScale(in);
    if (enlarge)
        temp.setOffset(in.offsetX - reX, in.offsetY - reY, in.offsetZ - reZ);
    else
        temp.setOffset(in);
    return temp;
}
Also used : ImageByte(mcib3d.image3d.ImageByte) ImageInt(mcib3d.image3d.ImageInt)

Example 5 with ImageByte

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

the class BinaryMorpho method binaryClose2D.

private static ImageByte binaryClose2D(ImageByte in, float radius) {
    ImageByte dilated = binaryDilate2D(in, radius, true);
    ImageByte close = binaryErode2D(dilated, radius);
    // crop image
    int ox = in.offsetX - dilated.offsetX;
    int oy = in.offsetY - dilated.offsetY;
    int oz = in.offsetZ - dilated.offsetZ;
    return close.crop3D("binaryClose", ox, ox + in.sizeX - 1, oy, oy + in.sizeY - 1, oz, oz + in.sizeZ - 1);
}
Also used : ImageByte(mcib3d.image3d.ImageByte)

Aggregations

ImageByte (mcib3d.image3d.ImageByte)22 ImageInt (mcib3d.image3d.ImageInt)13 ThreadRunner (mcib3d.utils.ThreadRunner)6 ImageFloat (mcib3d.image3d.ImageFloat)3 ImagePlus (ij.ImagePlus)1 Volume (ij3d.Volume)1 List (java.util.List)1 ImageShort (mcib3d.image3d.ImageShort)1