Search in sources :

Example 16 with ImageInt

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

the class IntImage3D method binaryReconstruct.

/**
 * Separate objects from an EDM image
 *
 * @return The segmented image with separated obects
 */
// public IntImage3D separateWatershed() {
// int val = this.getMaximum();
// IntImage3D seg = new IntImage3D(sizex, sizey, sizez);
// IntImage3D sep = new IntImage3D(sizex, sizey, sizez);
// IntImage3D neigh;
// int pix;
// int minVal;
// ArrayUtil tab;
// double val1;
// double val2;
// int c = 1;
// while (val >= 1) {
// // Find seeds
// for (int z = 0; z < sizez; z++) {
// for (int y = 0; y < sizey; y++) {
// for (int x = 0; x < sizex; x++) {
// pix = getPixel(x, y, z);
// if (pix == val) {
// tab = seg.getNeighborhood3x3x3(x, y, z);
// minVal = (int) tab.getMinimumAbove(0);
// if ((minVal == 0) && (isLocalMaximum(x, y, z, 2, 2, 2))) {
// seg.putPixel(x, y, z, c);
// seg.propagation(this, x, y, z, val, c);
// c++;
// }
// }
// }
// }
// }
// 
// //new ImagePlus("seg " + val, seg.getStack()).show();
// // Neighbor image
// int nb = 2;
// while (nb <= 2) {
// nb++;
// neigh = new IntImage3D(sizex, sizey, sizez);
// for (int z = 0; z < sizez; z++) {
// for (int y = 0; y < sizey; y++) {
// for (int x = 0; x < sizex; x++) {
// if (this.getPixel(x, y, z) > 0) {
// tab = seg.getNeighborhood3x3x3(x, y, z);
// if (!tab.hasOnlyValue(0)) {
// val1 = tab.getMinimumAbove(0);
// val2 = tab.getMinimumAbove(val1);
// if (val1 == val2) {
// neigh.putPixel(x, y, z, (int) val1);
// } else {
// sep.putPixel(x, y, z, 255);
// }
// }
// }
// }
// }
// }
// //new ImagePlus("neigh " + val, neigh.getStack()).show();
// seg = neigh;
// }
// val--;
// }
// return seg;
// }
/**
 * Description of the Method
 *
 * @param base Description of the Parameter
 * @return Description of the Return Value
 */
public ImageInt binaryReconstruct(ImageInt base) {
    int i;
    int j;
    int k;
    int val = 255;
    ImageInt res = new ImageByte("", sizex, sizey, sizez);
    // }
    return res;
}
Also used : ImageByte(mcib3d.image3d.ImageByte) ImageInt(mcib3d.image3d.ImageInt)

Example 17 with ImageInt

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

the class BinaryMorpho method binaryDilateMultilabel.

public static ImageInt binaryDilateMultilabel(ImageInt in, float radiusXY, float radiusZ, int nbCPUs) {
    // IJ.log("Binary multi dilate");
    ImageByte[] ihs = in.crop3DBinary();
    if (ihs != null) {
        // ij.IJ.log("BinaryClose multilabel nb :"+ihs.length);
        // ihs[0].show("crop binary 0");
        int end = ihs.length;
        for (int idx = 0; idx < end; idx++) {
            if (radiusXY < 1 && radiusZ < 1) {
                ihs[idx] = binaryDilateRad1(ihs[idx], 1, nbCPUs);
            } else if (radiusXY < 2 && radiusZ < 2) {
                ihs[idx] = binaryDilateRad1diag(ihs[idx], 1, nbCPUs);
            } else {
                ihs[idx] = binaryDilate(ihs[idx], radiusXY, radiusZ, 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 18 with ImageInt

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

the class BinaryMorpho method binaryDilateRad1.

private static ImageByte binaryDilateRad1(final ImageInt in_, final float thld, int nbCPUs) {
    if (nbCPUs == 0) {
        nbCPUs = ThreadUtil.getNbCpus();
    }
    final ImageInt in = (ImageInt) in_.resize(1, 1, 1);
    final ImageByte max = new ImageByte("max", in.sizeX, in.sizeY, in.sizeZ);
    final ThreadRunner tr = new ThreadRunner(0, in.sizeZ, nbCPUs);
    for (int i = 0; i < tr.threads.length; i++) {
        tr.threads[i] = new Thread(new Runnable() {

            @Override
            public void run() {
                for (int z = tr.ai.getAndIncrement(); z < tr.end; z = tr.ai.getAndIncrement()) {
                    for (int y = 0; y < in.sizeY; y++) {
                        for (int x = 0; x < in.sizeX; x++) {
                            if (maxRad1(in, thld, x, y, z)) {
                                max.pixels[z][x + y * in.sizeX] = (byte) 255;
                            }
                        }
                    }
                }
            }
        });
    }
    tr.startAndJoin();
    max.setScale(in);
    max.setOffset(in);
    return max;
}
Also used : ImageByte(mcib3d.image3d.ImageByte) ThreadRunner(mcib3d.utils.ThreadRunner) ImageInt(mcib3d.image3d.ImageInt)

Example 19 with ImageInt

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

the class BinaryMorpho method binaryDilateRad1diag.

private static ImageByte binaryDilateRad1diag(final ImageInt in_, final float thld, int nbCPUs) {
    if (nbCPUs == 0) {
        nbCPUs = ThreadUtil.getNbCpus();
    }
    final ImageInt in = (ImageInt) in_.resize(1, 1, 1);
    final ImageByte max = new ImageByte("max", in.sizeX, in.sizeY, in.sizeZ);
    final ThreadRunner tr = new ThreadRunner(0, in.sizeZ, nbCPUs);
    for (int i = 0; i < tr.threads.length; i++) {
        tr.threads[i] = new Thread(new Runnable() {

            @Override
            public void run() {
                for (int z = tr.ai.getAndIncrement(); z < tr.end; z = tr.ai.getAndIncrement()) {
                    for (int y = 0; y < in.sizeY; y++) {
                        for (int x = 0; x < in.sizeX; x++) {
                            if (maxRad15(in, thld, x, y, z)) {
                                max.pixels[z][x + y * in.sizeX] = (byte) 255;
                            }
                        }
                    }
                }
            }
        });
    }
    tr.startAndJoin();
    max.setScale(in);
    max.setOffset(in);
    return max;
}
Also used : ImageByte(mcib3d.image3d.ImageByte) ThreadRunner(mcib3d.utils.ThreadRunner) ImageInt(mcib3d.image3d.ImageInt)

Example 20 with ImageInt

use of mcib3d.image3d.ImageInt 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 (ihs != null) {
        // ij.IJ.log("BinaryClose multilabel nb :"+ihs.length);
        for (int idx = 0; idx < ihs.length; idx++) {
            if (radiusXY < 1 && radiusZ < 1) {
                ihs[idx] = binaryCloseRad1(ihs[idx], 1, nbCPUs);
            } else if (radiusXY < 2 && radiusZ < 2) {
                ihs[idx] = binaryCloseRad1diag(ihs[idx], 1, nbCPUs);
            } else if (radiusZ == 0) {
                ihs[idx] = binaryClose2D(ihs[idx], radiusXY);
            } else {
                ihs[idx] = binaryClose(ihs[idx], radiusXY, radiusZ, 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)

Aggregations

ImageInt (mcib3d.image3d.ImageInt)24 ImageByte (mcib3d.image3d.ImageByte)13 ImageShort (mcib3d.image3d.ImageShort)4 ThreadRunner (mcib3d.utils.ThreadRunner)4 Random (java.util.Random)3 ArrayList (java.util.ArrayList)2 Objects3DPopulation (mcib3d.geom.Objects3DPopulation)2 Point3D (mcib3d.geom.Point3D)2 Voxel3D (mcib3d.geom.Voxel3D)2 ImagePlus (ij.ImagePlus)1 Calibration (ij.measure.Calibration)1 ImageProcessor (ij.process.ImageProcessor)1 Volume (ij3d.Volume)1 List (java.util.List)1 ObjectCreator3D (mcib3d.geom.ObjectCreator3D)1 Voxel3DComparable (mcib3d.geom.Voxel3DComparable)1 ImageFloat (mcib3d.image3d.ImageFloat)1 ImageHandler (mcib3d.image3d.ImageHandler)1 ImageLabeller (mcib3d.image3d.ImageLabeller)1 Segment3DImage (mcib3d.image3d.Segment3DImage)1