Search in sources :

Example 6 with ArrayUtil

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

the class ImageInt method sobelFilter.

/**
 * Sobel-like filtering in 3D
 *
 * @return The 3D filtered image
 */
public ImageInt sobelFilter() {
    ImageInt res = (ImageInt) this.createSameDimensions();
    ArrayUtil nei;
    double[] edgeX = { -1, 0, 1, -2, 0, 2, -1, 0, 1, -2, 0, 2, -4, 0, 4, -2, 0, 2, -1, 0, 1, -2, 0, 2, -1, 0, 1 };
    double[] edgeY = { -1, -2, -1, 0, 0, 0, 1, 2, 1, -2, -4, -2, 0, 0, 0, 2, 4, 2, -1, -2, -1, 0, 0, 0, 1, 2, 1 };
    double[] edgeZ = { -1, -2, -1, -2, -4, -2, -1, -2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 2, 4, 2, 1, 2, 1 };
    double ex;
    double ey;
    double ez;
    double edge;
    for (int k = 0; k < sizeZ; k++) {
        // }
        for (int j = 0; j < sizeY; j++) {
            for (int i = 0; i < sizeX; i++) {
                nei = getNeighborhood3x3x3(i, j, k);
                ex = nei.convolve(edgeX, 1.0f);
                ey = nei.convolve(edgeY, 1.0f);
                ez = nei.convolve(edgeZ, 1.0f);
                edge = Math.sqrt(ex * ex + ey * ey + ez * ez);
                if ((edge > 65535) && (getType() == ImagePlus.GRAY16)) {
                    edge = 65535;
                }
                if ((edge > 255) && (getType() == ImagePlus.GRAY8)) {
                    edge = 255;
                }
                res.setPixel(i, j, k, (int) edge);
            }
        }
    }
    return res;
}
Also used : ArrayUtil(mcib3d.utils.ArrayUtil)

Example 7 with ArrayUtil

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

the class ImageInt method filterGeneric.

/**
 * 3D filter using threads
 *
 * @param out
 * @param radx   Radius of mean filter in x
 * @param rady   Radius of mean filter in y
 * @param radz   Radius of mean filter in z
 * @param zmin
 * @param zmax
 * @param filter
 */
public void filterGeneric(ImageInt out, float radx, float rady, float radz, int zmin, int zmax, int filter, Chrono timer, AbstractLog log) {
    int[] ker = FastFilters3D.createKernelEllipsoid(radx, rady, radz);
    int nb = FastFilters3D.getNbFromKernel(ker);
    if (zmin < 0) {
        zmin = 0;
    }
    if (zmax > this.sizeZ) {
        zmax = this.sizeZ;
    }
    int value;
    ArrayUtil tab;
    for (int k = zmin; k < zmax; k++) {
        // IJ.showStatus("3D filter : " + (k + 1) + "/" + zmax);
        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);
                if (filter == FastFilters3D.MEAN) {
                    out.setPixel(i, j, k, (int) (tab.getMean() + 0.5));
                } else if (filter == FastFilters3D.MEDIAN) {
                    out.setPixel(i, j, k, (int) tab.medianSort());
                }
                if (filter == FastFilters3D.MIN) {
                    out.setPixel(i, j, k, (int) tab.getMinimum());
                }
                if (filter == FastFilters3D.MAX) {
                    out.setPixel(i, j, k, (int) tab.getMaximum());
                }
                if (filter == FastFilters3D.VARIANCE) {
                    out.setPixel(i, j, k, (int) (tab.getVariance2() + 0.5));
                }
                if (filter == FastFilters3D.MAXLOCAL) {
                    value = this.getPixelInt(i, j, k);
                    if (tab.isMaximum(value)) {
                        out.setPixel(i, j, k, value);
                    } else {
                        out.setPixel(i, j, k, 0);
                    }
                }
            }
        }
        if (timer != null) {
            String ti = timer.getFullInfo(1);
            if (ti != null)
                log.log("3D filtering : " + ti);
        }
    }
    // ??
    resetStats();
}
Also used : ArrayUtil(mcib3d.utils.ArrayUtil)

Example 8 with ArrayUtil

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

the class ImageInt 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;
    }
    int 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.getPixelInt(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 9 with ArrayUtil

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

the class TrackThreshold method checkZoneColoc.

private double checkZoneColoc(Object3D object3D) {
    if (populationZones == null) {
        populationZones = new Objects3DPopulation(imageZones);
    }
    ArrayUtil arrayUtil = object3D.listValues(imageZones);
    arrayUtil = arrayUtil.distinctValues();
    double maxColoc = 0;
    for (double z : arrayUtil.getArrayList()) {
        if (z == 0)
            continue;
        Object3D zone = populationZones.getObjectByValue((int) (z));
        double coloc = object3D.pcColoc(zone);
        if (coloc > maxColoc)
            maxColoc = coloc;
    }
    return maxColoc;
}
Also used : ArrayUtil(mcib3d.utils.ArrayUtil)

Example 10 with ArrayUtil

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

the class Image3D method radialDistribution.

/**
 * Radial distribution of pixels mean values in layers
 *
 * @param x0 Coordinate x of the pixel
 * @param y0 Coordinate y of the pixel
 * @param z0 Coordinate z of the pixel
 * @param maxR maximu radius
 * @param water
 * @return arry with mean radial values
 */
public double[] radialDistribution(int x0, int y0, int z0, int maxR, IntImage3D water) {
    // int maxR = 10;
    double[] radPlot = new double[2 * maxR + 1];
    ArrayUtil raddist;
    int c = 0;
    int r;
    // compute radial means
    for (int i = -maxR; i <= 0; i++) {
        r = -i;
        raddist = getNeighborhoodLayer(x0, y0, z0, r, r + 1, water);
        if (raddist != null) {
            radPlot[c] = raddist.getMean();
        } else {
            radPlot[c] = Double.NaN;
        }
        c++;
    }
    for (int i = 1; i <= maxR; i++) {
        r = i;
        raddist = getNeighborhoodLayer(x0, y0, z0, r, r + 1, water);
        if (raddist != null) {
            radPlot[c] = raddist.getMean();
        } else {
            radPlot[c] = Double.NaN;
        }
        c++;
    }
    return radPlot;
}
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