Search in sources :

Example 6 with IntCoord3D

use of mcib3d.geom.IntCoord3D in project mcib3d-core by mcib3d.

the class Flood3D method flood3DNoise26.

public static void flood3DNoise26(ImageHandler img, IntCoord3D seed, int limit, int newVal) {
    // short[][] pixels = img.pixels;
    int sizeX = img.sizeX;
    int sizeY = img.sizeY;
    int sizeZ = img.sizeZ;
    // short oldVal = pixels[seed.z][seed.x + seed.y * sizeX];
    // short newval = (short) newVal;
    ArrayList<IntCoord3D> queue = new ArrayList<IntCoord3D>();
    queue.add(seed);
    while (!queue.isEmpty()) {
        // FIXME last element?
        IntCoord3D curCoord = queue.remove(0);
        // int xy = curCoord.x + curCoord.y * sizeX;
        if (img.getPixel(curCoord.x, curCoord.y, curCoord.z) >= limit) {
            // IJ.log("Flood " + curCoord.x + " " + curCoord.y + " " + curCoord.z + " " + img.getPixel(curCoord.x, curCoord.y, curCoord.z) + " " + limit);
            img.setPixel(curCoord.x, curCoord.y, curCoord.z, newVal);
            // pixels[curCoord.z][xy] = newval;
            int curZ, curY, curX;
            for (int zz = -1; zz < 2; zz++) {
                curZ = curCoord.z + zz;
                if ((curZ >= 0) && (curZ <= (sizeZ - 1))) {
                    for (int yy = -1; yy < 2; yy++) {
                        curY = curCoord.y + yy;
                        if ((curY >= 0) && (curY <= (sizeY - 1))) {
                            for (int xx = -1; xx < 2; xx++) {
                                curX = curCoord.x + xx;
                                if ((curX >= 0) && (curX <= (sizeX - 1))) {
                                    if (img.getPixel(curX, curY, curZ) >= limit) {
                                        queue.add(new IntCoord3D(curX, curY, curZ));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) IntCoord3D(mcib3d.geom.IntCoord3D)

Example 7 with IntCoord3D

use of mcib3d.geom.IntCoord3D in project mcib3d-core by mcib3d.

the class Flood3D method flood3DShort26.

private static void flood3DShort26(ImageShort img, IntCoord3D seed, short newVal) {
    short[][] pixels = img.pixels;
    int sizeX = img.sizeX;
    int sizeY = img.sizeY;
    int sizeZ = img.sizeZ;
    short oldVal = pixels[seed.z][seed.x + seed.y * sizeX];
    ArrayList<IntCoord3D> queue = new ArrayList<IntCoord3D>();
    queue.add(seed);
    while (!queue.isEmpty()) {
        // FIXME last element?
        IntCoord3D curCoord = queue.remove(0);
        int xy = curCoord.x + curCoord.y * sizeX;
        if (pixels[curCoord.z][xy] == oldVal) {
            pixels[curCoord.z][xy] = newVal;
            int curZ, curY, curX;
            for (int zz = -1; zz < 2; zz++) {
                curZ = curCoord.z + zz;
                if (curZ > 0 && curZ < (sizeZ - 1)) {
                    for (int yy = -1; yy < 2; yy++) {
                        curY = curCoord.y + yy;
                        if (curY > 0 && curY < (sizeY - 1)) {
                            for (int xx = -1; xx < 2; xx++) {
                                curX = curCoord.x + xx;
                                if (curX > 0 && curX < (sizeX - 1) && (xx != 0 || yy != 0 || zz != 0)) {
                                    if (pixels[curZ][curX + curY * sizeX] == oldVal) {
                                        queue.add(new IntCoord3D(curX, curY, curZ));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) IntCoord3D(mcib3d.geom.IntCoord3D)

Example 8 with IntCoord3D

use of mcib3d.geom.IntCoord3D in project mcib3d-core by mcib3d.

the class MaximaFinder method computePeaks.

private void computePeaks() {
    imagePeaks = new ImageShort("peaks", img.sizeX, img.sizeY, img.sizeZ);
    if (verbose) {
        IJ.log("Finding all peaks");
    }
    ArrayList<Voxel3DComparable> maximaTmp = FastFilters3D.getListMaxima(img, radXY, radXY, radZ, nbCpus, false);
    Collections.sort(maximaTmp);
    for (Voxel3DComparable V : maximaTmp) {
        imagePeaks.setPixel(V, (float) V.getValue());
    }
    if (verbose) {
        IJ.log(maximaTmp.size() + " peaks found");
    }
    if (verbose) {
        IJ.log("Removing peaks below noise");
    }
    maxima = new ArrayList<Voxel3D>();
    int c = 1;
    int nb = maximaTmp.size();
    Date start = new Date();
    Date temp;
    for (Voxel3DComparable V : maximaTmp) {
        if (img.getPixel(V) > 0) {
            if (V.getValue() > noiseTolerance) {
                maxima.add(V);
                if (verbose) {
                    temp = new Date();
                    if ((temp.getTime() - start.getTime()) > 100) {
                        IJ.showStatus("Processing peak " + c + "/" + nb + " " + V);
                        start = new Date();
                    }
                    c++;
                }
                Flood3D.flood3DNoise26(img, new IntCoord3D(V.getRoundX(), V.getRoundY(), V.getRoundZ()), (int) (Math.max(1, V.getValue() - noiseTolerance)), 0);
            }
        }
    }
    if (verbose) {
        IJ.log(maxima.size() + " peaks found");
    }
    if (verbose) {
        IJ.log("Creating final peaks");
    }
    imagePeaks.fill(0);
    for (Voxel3D V : maxima) {
        imagePeaks.setPixel(V, (float) V.getValue());
    }
    if (verbose) {
        IJ.log("MaximaFinder3D finished.");
    }
}
Also used : ImageShort(mcib3d.image3d.ImageShort) IntCoord3D(mcib3d.geom.IntCoord3D) Voxel3D(mcib3d.geom.Voxel3D) Voxel3DComparable(mcib3d.geom.Voxel3DComparable) Date(java.util.Date)

Aggregations

IntCoord3D (mcib3d.geom.IntCoord3D)8 ArrayList (java.util.ArrayList)6 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1 Voxel3D (mcib3d.geom.Voxel3D)1 Voxel3DComparable (mcib3d.geom.Voxel3DComparable)1 ImageShort (mcib3d.image3d.ImageShort)1