Search in sources :

Example 56 with ArrayUtil

use of mcib3d.utils.ArrayUtil in project mcib3d-core by mcib3d.

the class ImageFloat method getListMaxima.

public ArrayList<Voxel3DComparable> getListMaxima(float radx, float rady, float radz, int zmin, int zmax, Chrono timer, AbstractLog log) {
    ArrayList<Voxel3DComparable> res = new ArrayList<Voxel3DComparable>();
    int[] ker = FastFilters3D.createKernelEllipsoid(radx, rady, radz);
    int nb = FastFilters3D.getNbFromKernel(ker);
    if (zmin < 0) {
        zmin = 0;
    }
    if (zmax > this.sizeZ) {
        zmax = this.sizeZ;
    }
    float value;
    ArrayUtil tab;
    for (int k = zmin; k < zmax; k++) {
        for (int j = 0; j < sizeY; j++) {
            for (int i = 0; i < sizeX; i++) {
                tab = this.getNeighborhoodKernel(ker, nb, i, j, k, radx, rady, radz);
                value = this.getPixel(i, j, k);
                if (tab.isMaximum(value)) {
                    res.add(new Voxel3DComparable(i, j, k, value, 1));
                }
            }
        }
        if (timer != null) {
            String ti = timer.getFullInfo(1);
            if (ti != null)
                log.log("3D maxima : " + ti);
        }
    }
    return res;
}
Also used : ArrayList(java.util.ArrayList) ArrayUtil(mcib3d.utils.ArrayUtil)

Example 57 with ArrayUtil

use of mcib3d.utils.ArrayUtil in project mcib3d-core by mcib3d.

the class ImageHandler method getNeighborhoodXY3x3.

public ArrayUtil getNeighborhoodXY3x3(int x, int y, int z) {
    ArrayUtil res = new ArrayUtil(9);
    int idx = 0;
    int k = z;
    for (int j = y - 1; j <= y + 1; j++) {
        for (int i = x - 1; i <= x + 1; i++) {
            if ((i >= 0) && (j >= 0) && (k >= 0) && (i < sizeX) && (j < sizeY) && (k < sizeZ)) {
                res.putValue(idx, getPixel(i, j, k));
                idx++;
            }
        }
    }
    res.setSize(idx);
    return res;
}
Also used : ArrayUtil(mcib3d.utils.ArrayUtil)

Example 58 with ArrayUtil

use of mcib3d.utils.ArrayUtil in project mcib3d-core by mcib3d.

the class ImageHandler method getNeighborhoodKernelSubstract.

public ArrayUtil getNeighborhoodKernelSubstract(Object3D obj, ImageHandler img, int x, int y, int z) {
    int nbval = obj.getVolumePixels();
    ArrayUtil pix = new ArrayUtil(nbval);
    ImageHandler seg = obj.getLabelImage();
    int[] bb = obj.getBoundingBox();
    float radx = (float) (0.5 * (bb[1] - bb[0]));
    float rady = (float) (0.5 * (bb[3] - bb[2]));
    float radz = (float) (0.5 * (bb[5] - bb[4]));
    int vx = (int) Math.ceil(radx);
    int vy = (int) Math.ceil(rady);
    int vz = (int) Math.ceil(radz);
    int index = 0;
    int zmin = z - vz;
    if (zmin < 0) {
        zmin = 0;
    }
    int zmax = z + vz;
    if (zmax >= this.sizeZ) {
        zmax = this.sizeZ - 1;
    }
    int ymin = y - vy;
    if (ymin < 0) {
        ymin = 0;
    }
    int ymax = y + vy;
    if (ymax >= this.sizeY) {
        ymax = this.sizeY - 1;
    }
    int xmin = x - vx;
    if (xmin < 0) {
        xmin = 0;
    }
    int xmax = x + vx;
    if (xmax >= this.sizeX) {
        xmax = this.sizeX - 1;
    }
    int tx = xmin - bb[0];
    int ty = ymin - bb[2];
    int tz = zmin - bb[4];
    float diff;
    for (int k = zmin; k <= zmax; k++) {
        for (int j = ymin; j <= ymax; j++) {
            for (int i = xmin; i <= xmax; i++) {
                if ((seg.contains(i - tx, j - ty, k - tz)) && (seg.getPixel(i - tx, j - ty, k - tz) > 0)) {
                    diff = this.getPixel(i, j, k) - img.getPixel(i - tx, j - ty, k - tz);
                    pix.putValue(index, diff);
                    index++;
                }
            }
        }
    }
    pix.setSize(index);
    return pix;
}
Also used : ArrayUtil(mcib3d.utils.ArrayUtil)

Example 59 with ArrayUtil

use of mcib3d.utils.ArrayUtil in project mcib3d-core by mcib3d.

the class ImageHandler method getNeighborhoodKernel.

/**
 * Gets the neighboring attribute of the Image3D with a kernel as a array
 *
 * @param ker   The kernel array (>0 ok)
 * @param nbval The number of non-zero values
 * @param x     Coordinate x of the pixel
 * @param y     Coordinate y of the pixel
 * @param z     Coordinate z of the pixel
 * @param radx  Radius x of the neighboring
 * @param radz  Radius y of the neighboring
 * @param rady  Radius z of the neighboring
 * @return The values of the nieghbor pixels inside an array
 */
public ArrayUtil getNeighborhoodKernel(int[] ker, int nbval, int x, int y, int z, float radx, float rady, float radz) {
    ArrayUtil pix = new ArrayUtil(nbval);
    int vx = (int) Math.ceil(radx);
    int vy = (int) Math.ceil(rady);
    int vz = (int) Math.ceil(radz);
    int index = 0;
    int c = 0;
    for (int k = z - vz; k <= z + vz; k++) {
        for (int j = y - vy; j <= y + vy; j++) {
            for (int i = x - vx; i <= x + vx; i++) {
                if (ker[c] > 0) {
                    if ((i >= 0) && (j >= 0) && (k >= 0) && (i < sizeX) && (j < sizeY) && (k < sizeZ)) {
                        pix.putValue(index, getPixel(i, j, k));
                        index++;
                    }
                }
                c++;
            }
        }
    }
    pix.setSize(index);
    return pix;
}
Also used : ArrayUtil(mcib3d.utils.ArrayUtil)

Example 60 with ArrayUtil

use of mcib3d.utils.ArrayUtil in project mcib3d-core by mcib3d.

the class ImageHandler method getNeighborhoodKernel.

public ArrayUtil getNeighborhoodKernel(Object3D obj, int x, int y, int z) {
    int nbval = obj.getVolumePixels();
    ArrayUtil pix = new ArrayUtil(nbval);
    ImageHandler seg = obj.getLabelImage();
    int[] bb = obj.getBoundingBox();
    float radx = (float) (0.5 * (bb[1] - bb[0]));
    float rady = (float) (0.5 * (bb[3] - bb[2]));
    float radz = (float) (0.5 * (bb[5] - bb[4]));
    int vx = (int) Math.ceil(radx);
    int vy = (int) Math.ceil(rady);
    int vz = (int) Math.ceil(radz);
    int index = 0;
    int zmin = z - vz;
    if (zmin < 0) {
        zmin = 0;
    }
    int zmax = z + vz;
    if (zmax >= this.sizeZ) {
        zmax = this.sizeZ - 1;
    }
    int ymin = y - vy;
    if (ymin < 0) {
        ymin = 0;
    }
    int ymax = y + vy;
    if (ymax >= this.sizeY) {
        ymax = this.sizeY - 1;
    }
    int xmin = x - vx;
    if (xmin < 0) {
        xmin = 0;
    }
    int xmax = x + vx;
    if (xmax >= this.sizeX) {
        xmax = this.sizeX - 1;
    }
    int tx = xmin - bb[0];
    int ty = ymin - bb[2];
    int tz = zmin - bb[4];
    for (int k = zmin; k <= zmax; k++) {
        for (int j = ymin; j <= ymax; j++) {
            for (int i = xmin; i <= xmax; i++) {
                if ((seg.contains(i - tx, j - ty, k - tz)) && (seg.getPixel(i - tx, j - ty, k - tz) > 0)) {
                    pix.putValue(index, this.getPixel(i, j, k));
                    index++;
                }
            }
        }
    }
    pix.setSize(index);
    return pix;
}
Also used : ArrayUtil(mcib3d.utils.ArrayUtil)

Aggregations

ArrayUtil (mcib3d.utils.ArrayUtil)66 ArrayList (java.util.ArrayList)9 Iterator (java.util.Iterator)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Voxel3D (mcib3d.geom.Voxel3D)2 Voxel3DComparable (mcib3d.geom.Voxel3DComparable)2 RoiManager (ij.plugin.frame.RoiManager)1 HashMap (java.util.HashMap)1 Random (java.util.Random)1 Point3D (mcib3d.geom.Point3D)1 Vector3D (mcib3d.geom.Vector3D)1 ImageInt (mcib3d.image3d.ImageInt)1