Search in sources :

Example 46 with ArrayUtil

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

the class IntImage3D 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(IntImage3D out, float radx, float rady, float radz, int zmin, int zmax, int filter) {
    int[] ker = createKernelEllipsoid(radx, rady, radz);
    int nb = 0;
    for (int i = 0; i < ker.length; i++) {
        nb += ker[i];
    }
    if (zmin < 0) {
        zmin = 0;
    }
    if (zmax > this.getSizez()) {
        zmax = this.getSizez();
    }
    int value;
    for (int k = zmin; k < zmax; k++) {
        if (this.showStatus) {
            IJ.showStatus("3D filter : " + k + "/" + zmax);
        }
        for (int j = 0; j < sizey; j++) {
            for (int i = 0; i < sizex; i++) {
                ArrayUtil tab = this.getNeighborhoodKernel(ker, nb, i, j, k, radx, rady, radz);
                if (filter == FastFilters3D.MEAN) {
                    out.putPixel(i, j, k, tab.getMean());
                } else if (filter == FastFilters3D.MEDIAN) {
                    out.putPixel(i, j, k, tab.medianSort());
                }
                if (filter == FastFilters3D.MIN) {
                    out.putPixel(i, j, k, tab.getMinimum());
                }
                if (filter == FastFilters3D.MAX) {
                    out.putPixel(i, j, k, tab.getMaximum());
                }
                if (filter == FastFilters3D.VARIANCE) {
                    out.putPixel(i, j, k, tab.getVariance2());
                }
                if (filter == FastFilters3D.MAXLOCAL) {
                    value = this.getPixel(i, j, k);
                    if (tab.isMaximum(value)) {
                        out.putPixel(i, j, k, value);
                    } else {
                        out.putPixel(i, j, k, 0);
                    }
                }
            }
        }
    }
}
Also used : ArrayUtil(mcib3d.utils.ArrayUtil)

Example 47 with ArrayUtil

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

the class IntImage3D method morpho3Dbin.

/**
 * Morphologie binaire 3D avec kernel
 *
 * @param fond Valeur du fond
 * @param obj Valeur des objets
 * @param ker Noyau (>0 inside kernel, 0 outside kernel)
 * @return Image transformee
 */
private IntImage3D morpho3Dbin(int obj, int fond, Image3D ker) {
    int p;
    IntImage3D morphoimg = new IntImage3D(sizex, sizey, sizez, type);
    ArrayUtil tab;
    for (int k = 0; k < sizez; k++) {
        for (int j = 0; j < sizey; j++) {
            for (int i = 0; i < sizex; i++) {
                p = getPixel(i, j, k);
                if (p == obj) {
                    morphoimg.putPixel(i, j, k, p);
                } else {
                    tab = this.getNeighborhood(ker, i, j, k);
                    if (!tab.hasOnlyValue(fond)) {
                        morphoimg.putPixel(i, j, k, obj);
                    } else {
                        morphoimg.putPixel(i, j, k, fond);
                    }
                }
            }
        }
    }
    return morphoimg;
}
Also used : ArrayUtil(mcib3d.utils.ArrayUtil)

Example 48 with ArrayUtil

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

the class Object3DSurface method listValues.

@Override
public ArrayUtil listValues(ImageHandler ima, float thresh) {
    ArrayUtil vector = new ArrayUtil(this.getVolumePixels());
    float pixvalue;
    int idx = 0;
    for (Voxel3D pixel : voxels) {
        if (ima.contains(pixel)) {
            pixvalue = ima.getPixel(pixel);
            if (pixvalue > thresh) {
                vector.addValue(idx, pixvalue);
                idx++;
            }
        }
    }
    vector.setSize(idx);
    return vector;
}
Also used : ArrayUtil(mcib3d.utils.ArrayUtil)

Example 49 with ArrayUtil

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

the class Object3DVoxels method listValues.

@Override
public ArrayUtil listValues(ImageHandler ima, float thresh) {
    ArrayUtil list = new ArrayUtil(this.getVolumePixels());
    Voxel3D voxel;
    Iterator<Voxel3D> it = voxels.iterator();
    int idx = 0;
    while (it.hasNext()) {
        voxel = it.next();
        if (ima.contains(voxel.getX(), voxel.getY(), voxel.getZ())) {
            float pix = ima.getPixel(voxel);
            if (pix > thresh) {
                list.putValue(idx, pix);
                idx++;
            }
        }
    }
    list.setSize(idx);
    return list;
}
Also used : ArrayUtil(mcib3d.utils.ArrayUtil)

Example 50 with ArrayUtil

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

the class Object3DVoxels method drawContoursXY.

public void drawContoursXY(ObjectCreator3D ima, int z, int col) {
    Voxel3D p2;
    ImageHandler seg = getMaxLabelImage(1);
    for (Voxel3D contour : contours) {
        p2 = contour;
        if (Math.abs(p2.getZ() - z) < 0.5) {
            ArrayUtil arrayUtil = seg.getNeighborhoodXY3x3(p2.getRoundX(), p2.getRoundY(), p2.getRoundZ());
            if (arrayUtil.hasValue(0))
                ima.createPixel(p2.getRoundX(), p2.getRoundY(), p2.getRoundZ(), col);
        }
    }
}
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